package com.anxin.act.wfEntrustTask.web;

import java.util.List;

import com.anxin.act.wfEntrustTask.service.WfEntrustTaskService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.anxin.framework.aspectj.lang.annotation.Log;
import com.anxin.framework.aspectj.lang.enums.BusinessType;
import com.anxin.act.wfEntrustTask.entity.WfEntrustTask;

import com.anxin.framework.web.controller.BaseController;
import com.anxin.framework.web.entity.AjaxResult;
import com.anxin.common.utils.poi.ExcelUtil;
import com.anxin.framework.web.page.TableDataInfo;

/**
 * 委托代办Controller
 *
 * @author jbs
 * @date 2021-11-18
 */
//@Api(tags = "委托代办" )
@RestController
@RequestMapping("/entrust/wfEntrustTask")
public class WfEntrustTaskController extends BaseController{
    @Autowired
    private WfEntrustTaskService wfEntrustTaskService;

    /**
     * 查询委托代办列表
     */
    //@ApiOperation(value="查询委托代办列表" ,notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:entrust:view')")
    @GetMapping("/list")
    @Log(title = "查询委托代办列表", businessType = BusinessType.LIST)
    public TableDataInfo<List<WfEntrustTask>> list(WfEntrustTask wfEntrustTask){
        startPage();
        List<WfEntrustTask> list = wfEntrustTaskService.findList(wfEntrustTask);
        return getDataTable(list);
    }

    /**
     * 导出委托代办列表
     */
    //@ApiOperation(value="导出委托代办列表",notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:entrust:export')")
    @Log(title = "委托代办", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WfEntrustTask wfEntrustTask) {
        List<WfEntrustTask> list = wfEntrustTaskService.findList(wfEntrustTask);
        ExcelUtil<WfEntrustTask> util = new ExcelUtil<WfEntrustTask>(WfEntrustTask.class);
        return util.exportExcel(list, "entrust");
    }

    /**
     * 获取委托代办详细信息
     */
    //@ApiOperation(value="获取委托代办详细信息",notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:entrust:view')")
    @GetMapping(value = "/{id}")
    @Log(title = "获取委托代办详细信息", businessType = BusinessType.LIST)
    public AjaxResult<WfEntrustTask> getInfo(@PathVariable("id") String id){
        return AjaxResult.success(wfEntrustTaskService.getById(id));
    }

    /**
     * 保存委托代办
     */
    //@ApiOperation(value="保存委托代办",notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:entrust:edit')")
    @Log(title = "委托代办", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    public AjaxResult save(@RequestBody WfEntrustTask wfEntrustTask){
        return AjaxResult.success(wfEntrustTaskService.save(wfEntrustTask));
    }

    /**
     * 删除委托代办
     */
    //@ApiOperation(value="删除委托代办",notes="作者:jbs")
    @PreAuthorize("@ss.hasPermi('act:entrust:remove')")
    @Log(title = "委托代办", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable(("id")) String id){
        return toAjax(wfEntrustTaskService.deleteById(id));
    }

    /**
     * 修改状态
     * @param wfEntrustTask
     * @return
     */
    @PreAuthorize("@ss.hasPermi('act:entrust:edit')")
    @Log(title = "委托代办", businessType = BusinessType.INSERT)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody WfEntrustTask wfEntrustTask){
        return toAjax(wfEntrustTaskService.updateStatus(wfEntrustTask));
    }

}
